package com.zklh.leetcode.greedy.middle.problem991;
/**
 * @descrpiton 
 * @author 坐看落花
 * @version 1.0
 * @date 2020/6/3
 */
public class Solution {

    public int brokenCalc(int X, int Y) {
        if (X > Y) {
            return X - Y;
        } else if (Y % X == 0 && Math.log(Y / X) / Math.log(2) % 1 == 0) {
            return (int)(Math.log(Y / X) / Math.log(2)) ;
        } else {
            if (Y % 2 == 0) {
                return brokenCalc(X, Y / 2) + 1;
            } else {
                return brokenCalc(X, Y+1) + 1;
            }
        }
    }

    public static void main(String[] args){
        Solution solution = new Solution();
        System.out.println(solution.brokenCalc(1, 1));
        System.out.println( 9 );
        System.out.println(1.5 % 1);
    }


}

